package com.hall.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class TencentMessageUtils implements InitializingBean {

    //读取全局配置文件内容进行赋值
    @Value("${tencent.message.appId}")
    private String appId;

    @Value("${tencent.message.KeyId}")
    private String keyId;

    @Value("${tencent.message.templateId}")
    private String templateId;

    @Value("${tencent.message.smsSign}")
    private String smsSign="群爱科技";

    @Value("${tencent.message.secretId}")
    private String secretId;

    @Value("${tencent.message.secretKey}")
    private String secretKey;
    //定义公开静态常量从而通过静态变量使用private变量
    public static String APP_ID;
    public static String KEY_ID;
    public static String TEMPLATE_ID;
    public static String SMS_SIGN;
    public static String SECRET_ID;
    public static String SECRET_KEY;

    @Override
    public void afterPropertiesSet() throws Exception {
        APP_ID = appId;
        KEY_ID = keyId;
        TEMPLATE_ID = templateId;
        SMS_SIGN = smsSign;
        SECRET_ID = secretId;
        SECRET_KEY = secretKey;
    }
}
